package com.bilibili.service.impl;

import java.util.List;

import com.bilibili.dao.CategoryDao;
import com.bilibili.dao.CommentDao;
import com.bilibili.dao.VideoAndCategoryDao;
import com.bilibili.dao.impl.CategoryDaoImpl;
import com.bilibili.dao.impl.CommentDaoImpl;
import com.bilibili.dao.impl.VideoAndCategoryDaoImpl;
import com.bilibili.dto.VideoAndCategory;
import com.bilibili.entity.Page;
import com.bilibili.service.VideoAndCategoryService;

public class VideoAndCategoryServiceImpl implements VideoAndCategoryService {

	VideoAndCategoryDao vacd = new VideoAndCategoryDaoImpl();
	CategoryDao cd = new CategoryDaoImpl();
	CommentDao c = new CommentDaoImpl();
	@Override
	public Page<VideoAndCategory> selectMyAllsendVideo(VideoAndCategory vac, int pageNum, int pageSize) {
		// TODO Auto-generated method stub
		List<VideoAndCategory> vacList = vacd.selectMyAllsendVideo(vac, pageNum, pageSize);
		for (VideoAndCategory v : vacList) {
			v.setName(cd.selectCategoryIdById(v.getCategoryId()).getName());
			v.setCommentNum(c.selectVideoPlayNum(v.getVideoId()));
		}
		int totalRows = vacd.selectMyAllsendVideoNum(vac);
		Page<VideoAndCategory> vacPage = new Page<VideoAndCategory>(vacList,pageNum,pageSize,totalRows);
		return vacPage;
	}

}
